package com.xl.observer.weather;

import java.util.ArrayList;
import java.util.List;

public class WeatherSubject {

    private List<WeatherObserver> observers = new ArrayList<>();

    public void attach(WeatherObserver observer) {
        observers.add(observer);
    }

    public void deltach(WeatherObserver observer) {
        observers.remove(observer);
    }

    /**
     * 通知
     */
    public void notifyObserver(String content) {
        for (WeatherObserver observer : observers) {
            observer.update(content);
        }
    }


    /**
     * 通知
     */
    public void notifyObserver() {
        for (WeatherObserver observer : observers) {
            observer.update(this);
        }
    }


}
